<!-- Home -->
<div data-role="page" id="main">
    <div data-theme="b" data-role="header">
         <h5 class="header_logo">
           <img src="mobile/img/header_logo.png">
        </h5>
    </div>
    <div data-role="content">
        <div style=" text-align:center">
            <img style="width: 130x; height: 150px" src="content/img/biglogo.png" />
        </div>
        <p class="lead">ברוכים הבאים לSafTalk</p>
        <a href="#!/login" data-role="button" data-theme="b" data-icon="arrow-l" data-iconpos="left">
            הכנסו
        </a>
    </div>
    <div data-theme="b" data-role="footer" data-position="fixed">
        <h3>

        </h3>
    </div>
</div>


<div id="login" data-role="page" ng-controller="LoginCtrl" >
    <div data-theme="b" data-role="header">
        <h3>
            התחברות למערכת
        </h3>
    </div>
    <div data-role="content" class="loginForm">
        <div data-role="fieldcontain">
            <fieldset data-role="controlgroup">
                <label for="textinput1">
                    דואר אלקטרוני
                </label>
                <input name="" id="textinput1" placeholder="" value="" type="email" ng-model="email"/>
            </fieldset>
        </div>
        <div data-role="fieldcontain">
            <fieldset data-role="controlgroup">
                <label for="textinput2">
                    סיסמא
                </label>
                <input name="" id="textinput2" placeholder="" value="" type="password" ng-model="password" />
            </fieldset>
        </div>
        <input type="submit" data-theme="b" value="{{submitButton.label}}" ngm-vclick="login()"/>
        <div class="login-alerts">
            <div class="alert alert-error hidden">
                חלה שגיאה! הסיסמא אינה נכונה
            </div>
        </div>
    </div>
</div>


<!-- Home -->
<div data-role="page" id="chat" ng-controller="ChatCtrl">
    <script src="content/js/pubnub-3.4.min.js"></script>
    <div data-theme="b" data-role="header">
        <a data-role="button" data-theme="b" href="saftalk/logout" data-icon="back" data-iconpos="left" class="ui-btn-left">
            התנתק
        </a>
        <a href="" ngm-vclick="goToSurvey()" data-role="button" id="gotoSurveyButton" data-icon="plus" class="ui-btn-right"  >שלח סקר</a>
        <h5 class="header_logo">
             <img src="mobile/img/header_logo.png">
        </h5>
    </div>
    <div data-role="content" id="messages">
        <div  ng-repeat="message in messages | filter:isMessage" class="message" ng-class="{activeMsg:$last && (message.type=='message' || message.type=='image' || message.type=='survey' )}" ng-switch on="message.type" cool-fade>
            <div class="userInfo">
									<span class="photo">
                                        <img ng-src="{{getImageUrl(message.photoId)}}" />
									</span>
                <span class="username" fit-text="0.5">{{message.username}}</span>
            </div>
            <div class="arrow_box">
                <div ng-show="message.type!='survey'">
                    {{message.text}}
                </div>
                <div ng-show="message.type=='image'" class="image-message">
                    <p><a ng-click="popupImage(message.image)"><img ng-src="/image/thumb?key={{message.image}}"></a></p>
                </div>
                <div ng-show="message.type=='survey' && message.survey.status=='new'">
                    סקר: "{{ message.survey.question}}"
                </div>
                <div ng-show="message.type=='survey' && message.survey.status!='new'" class="surveyAnswers">
                    {{ message.survey.username}}: "{{ message.survey.question}}"
                    <br/>
                    תשובת {{message.username}}:
                    <span ng-repeat="answer in message.survey.answers" class="label"  ng-class="{'label-success':$index+1==message.survey.answerid}"><i class="icon-ok icon-white" ng-show="$index+1==message.survey.answerid"></i> {{answer}}</span>
                </div>
                <div class="datetime">{{timeFormatter(message.time)}}</div>
            </div>
        </div>
    </div>
    <div data-theme="b" data-role="footer" data-position="fixed" data-tap-toggle="false">
            <form id="messageTextFieldset" ng-submit="publish()" data-role="controlgroup" data-ajax="false">
                <input name="" id="textInput" type="text" ng-model="message.text">
            </form>
        <a data-role="button" ngm-vclick="publish()" id="sendMessageButton" data-icon="plus" class="ui-btn-left" >שלח</a>
    </div>
</div>


<div id="survey" data-role="page" ngm-swipeleft="back()" ng-controller="ChatCtrl">
    <div data-role="header" data-theme="b">
        <h1>שליחת סקר</h1>
        <a href="" id="goBack" data-role="button" class="ui-btn-left" ngm-vclick="back()">חזרה</a>
    </div>
    <div data-role="content">
        <div data-role="fieldcontain">
            <input type="text" id="queryQuestion" ng-model="survey.question" placeholder="מה תרצו לשאול">
            <form ng-submit="addSurveyAnswer()" id="sendSurveyForm" data-ajax="false">
                <input type="text" id="queryAnswerText" ng-model="newSurveyAnswer" placeholder=" הוסיפו תשובה">
                <a data-role="button" id="addAnswerButton" data-icon="plus" class="ui-btn-left" ngm-vclick="addSurveyAnswer()" >הוסף</a>
            </form>
        </div>
        <div data-role="controlgroup">
            <fieldset ng-repeat="answer in survey.answers">
                <a data-role="button" class="answer" ng-class="delete" data-icon="delete"
                   data-iconpos="right" class="ui-btn-right" ngm-vclick="removeSurveyAnswer($index)" >{{answer}}</a>
            </fieldset>
        </div>
        <input type="submit" value="שלח" data-theme="b" ngm-vclick="sendSurvey()">
    </div>
</div>


